/**
  ******************************************************************************
  * @file           : usart.h
  * @brief          : Header for usart.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USART_H
#define __USART_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "xl32f003xx_ll_Start_Kit.h"

/* Private includes ----------------------------------------------------------*/
#define RX_BUFF_LEN    30
#define TX_BUFF_LEN    30
/* Exported types ------------------------------------------------------------*/

typedef struct 
{
    uint8_t rx_flag;
    uint8_t tx_flag;
    uint8_t rxbuff[RX_BUFF_LEN];
    uint8_t txbuff[TX_BUFF_LEN];
    uint16_t rx_len;
    uint16_t tx_len;

}Usart_buff_TypeDef;


/* Exported constants --------------------------------------------------------*/
extern Usart_buff_TypeDef uasrt_data;
/* Exported macro ------------------------------------------------------------*/
/* Exported functions prototypes ---------------------------------------------*/

void APP_UsartIRQCallback(USART_TypeDef *USARTx);
void APP_DmaChannel1IRQCallback(void);
void APP_DmaChannel2_3_IRQCallback(void);


void APP_ConfigDma(USART_TypeDef *USARTx);
void APP_UsartTransmit_DMA(USART_TypeDef *USARTx, uint8_t *pData, uint16_t Size);
void APP_UsartReceive_DMA(USART_TypeDef *USARTx, uint8_t *pData, uint16_t Size);
void APP_ConfigUsart(USART_TypeDef *USARTx,uint32_t BaudRate);

void usart_init(void);
void usart_task(void);

void usart_send_key_buff(uint8_t addr,uint8_t num,uint8_t * buff);
/* Private defines -----------------------------------------------------------*/

#ifdef __cplusplus
}
#endif

#endif /* __USART_H */

/************************ (C) COPYRIGHT Xinling *****END OF FILE****/
